package com.atguigu.Mapper;

import com.atguigu.Bean.OrderBean;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class GroupMapper extends Mapper<LongWritable, Text, OrderBean, NullWritable> {
    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        //分割获取到的数据
        String[] split = value.toString().split("\t");

        //创建orderBean对象
        OrderBean orderBean = new OrderBean();
        //给orderId赋值
        orderBean.setOrderId(split[0]);
        //给price赋值
        orderBean.setPrice(Double.valueOf(split[2]));

        context.write(orderBean, NullWritable.get());
    }
}
